<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.global.js"></script>
</head>
<style>
    body,ul,li{
        padding: 0;
        margin: 0;
    }
    ul{
        list-style: none;
        display: flex;
    }
    li{
        padding: 20px;
        background-color: antiquewhite;
        margin-right: 10px;
    }
    .red{
        background-color: red;
        color: aliceblue;
    }
    img{
        width: 400px;
        height: 400px;
    }
</style>
<body>
    <div class="app">
        <ul>
            <li 
            v-for="(v,i) in movies" 
            :class="{red:v.id==index}"
            @click="index = v.id"
            >{{v.name}}</li>
        </ul>
        <img :src="movies[`${index}`].src"  alt="" srcset="">
    </div>
    <script>
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    movies: [
                        {
                            id: 0,
                            name: "《新蝙蝠侠》",
                            src: "./img/新蝙蝠侠.webp"
                        },
                        {
                            id: 1,
                            name: "《楚门的世界》",
                            src: "./img/楚门的世界.webp"
                        }
                    ],
                    index: 0,
                    src: "./img/新蝙蝠侠.webp",
                }
            }
        }).mount('.app')
    </script>
</body>

</html>